package com.blyat.xsoft.kernel.component.pool;

import org.apache.commons.pool2.impl.GenericObjectPool;

import java.util.function.Function;

/**
 * @Auther: syh
 * @Date: 2020/8/4
 * @Description:
 */
public interface Provider<T> {
    /**
     * 同步创建连接
     * @param function
     * @return
     */
    default T syncConnect(Function<GenericObjectPool<T>, T> function) {
        return null;
    }

    /**
     * 异步创建连接
     * @param function
     * @return
     */
    default T asyncConnect(Function<GenericObjectPool<T>, T> function) {
        return null;
    }

    /**
     * 从连接池中获取连接
     * @return
     */
    T getPooledObject();
}
